/*
 * Copyright (C) 2013 Fabiano Tarlao
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package org.easybenchmark.client.arbiter;

import java.util.LinkedList;
import org.easybenchmark.client.benchmarks.Benchmark;

/**
 *Collects results, save them
 * @author Fabiano Tarlao
 */
public class ResultManager extends LinkedList<Result> {

    /**
     * Initialize ResultSet by specifing the nma eof the architecture, Vm, or system.. it should be the ID of the experiment set.
     * @param targetVM
     */
    public ResultManager(String targetVM) {
        this.targetVM = targetVM;
    }
    
    String targetVM;

    public void setTargetVM(String targetVM) {
        this.targetVM = targetVM;
    }
    

    public boolean add(Benchmark benchmark) {
        Result result = benchmark.getResult();
        result.targetVM=this.targetVM;
        return super.add(result);
    }   
    
    public String toCSVString(){
        StringBuilder outString = new StringBuilder();
        for (Result result : this) {
            outString.append(result.toCSVString()).append("\n");
        }
        return outString.toString();
    }
    
    public String getCSVColumnNames(){
        return Result.csvColumnNames;
    }
}
